<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<title>添加业务员</title>
    <script src="__JS__/zepto.min.js"></script>
    <link href="__CSS__/weui.min.css" rel="stylesheet">
	<link rel="stylesheet" href="__SaleManager__/stylesheets/index.css">
</head>
<body>
	<div class="countyInfo">
  	<header class = "all_header">
       <a class = "h_back_1" style='flex: 1;' href="/Home/SaleManager/County/mySaleMan"><img src="__SaleManager__/images/back_icon.png" alt="" style="width:30px;vertical-align: middle;"></a>
      <span class = "h_title">添加业务员</span>
      <a class = "h_add" href="javascript:void(0)"></a>
    </header>
    <form action='./addSaleman/f/page/x/nosecret' name='form1' method='POST' id='addsale'>
		<div class="weui-cells">
      <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" type="text" name='real_name' id='real_name' placeholder="请输入姓名">
          </div>
      </div>
      <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
          <div class="weui-cell__bd">
              <input class="weui-input" type="number" name='phone'  id='phone' pattern="[0-9]*" placeholder="请输入手机号">
          </div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">身份证号</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" type="text" name='card_number' id='card_number' placeholder="请输入身份证号">
        </div>
      </div>
      <div class="weui-cell weui-cell_select" style = "padding: 0;">
        <div class="weui-cell__bd">
          <p style = "padding-left: 15px;">性别</p>
        </div>
        <div class="weui-cell__bd">
          <select class="weui-select" name="sex" id='sex'>
            <option selected="" value="1">男</option>
            <option value="2">女</option>
          </select>
        </div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">年龄</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="number" name='age'id='age' pattern="[0-9]*" placeholder="请输入年龄">
        </div>
      </div>
      <!-- <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">所属县</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" type="text"  name='belong_locations' id='belong_locations' placeholder="请输入所属县">
        </div>
      </div> -->
    </div>
    </form>
    <div class="weui-btn-area" style="background-color:#6db0e4;border-radius:5px">
	    <a class="weui-btn change_btn" href="javascript:">确定</a>
	  </div>
	</div>
	<include file="./Application/Home/View/default/SaleManager/layer/popup.html"/>
</body>
<script src = "__SaleManager__/js/Common.js"></script>
<script src = "__SaleManager__/js/androidback.js"></script>
<script>
	/* $(document).on('click','.change_btn',function(){
		$('#addsale').submit();
	}) */
	var sessioncode;
	var nosesstion_url;
	var returnStatus;
	//返回操作
	$(document).on('click','.h_back',function(){
		location.href=document.referrer;
	})
	//删除事件
		$(document).on("click",".change_btn",function(){
			 var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; 
		      var telReg = /^0?1[3|4|5|8][0-9]\d{8}$/;
		 
		      if (reg.test($("#card_number").val()) === false) { 
		    	  	$('.weui-dialog__bd').html('身份证输入不合法');
           		$('#confirm_dialog').css('display','block');
		         return false;  
		      };
		      if (telReg.test($("#phone").val()) === false) { 
		      //  $(".dialogCont").html("手机号输入不合法");
		        $('.weui-dialog__bd').html('手机号输入不合法');
           		$('#confirm_dialog').css('display','block');
		         return false;  
		      };
		      if ($("#age").val() < 1 || $("#age").val() > 200) {
		       // $(".dialogCont").html("年龄在1-200之间");
		        $('.weui-dialog__bd').html('年龄在1-200之间');
           		$('#confirm_dialog').css('display','block');
		        return false;
		      }
			$.ajax({
                url: "",
                type: 'POST',
                data: {'real_name':$("#real_name").val(),'phone':$("#phone").val(),'card_number':$("#card_number").val(),'sex':$("#sex").val(),'age':$("#age").val(),'belong_locations':$("#belong_locations").val()},
                async: false,
                cache: false,
               	dataType:"json",
                success: function (returndata) {
                	//session失效
               	 	returnStatus=returndata.code;
               	 	if(returndata.code==2028){
               	 		sessioncode=2028;
               	 		nosesstion_url=returndata.data;
	        	       	 	$('.weui-dialog__bd').html(returndata.msg);
	        	     		$('#confirm_dialog').css('display','block');
               	 	}else{
	               	 	$('.weui-dialog__bd').html(returndata.msg);
	             		$('#confirm_dialog').css('display','block');
               	 	}
                },
                error: function (returndata) {
                		$('.weui-dialog__bd').html(returndata.msg);
             		$('#confirm_dialog').css('display','block');
                }
            });
			$(document).on('click','.weui-dialog__btn_primary',function(){
				if(sessioncode==2028){
					window.location.href=nosesstion_url;
				}else{
					if(returnStatus==1){
						location.href=document.referrer;
					}else{
						return false;
					}
					
				}
			})
		})
</script>
</html>